Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

273
Vistas
How to have a searchbar in "Select" Component native-base

I would love to have a search bar in "Select" component from the library native-base in react-native.

I have tried adding a "TextInput" component inside the "Select" component. In UI it aligns perfectly, but when I click on the "TextInput" it gets selected and the list drops down.

Following is the code I tried:

                     <Select
                    w={w}
                    h={h}
                    variant="outline"
                    selectedValue={selectedValue}
                    minWidth="200"
                    // borderColor={primaryColor}
                    accessibilityLabel={accessibilityLabel?accessibilityLabel: "Choose Service" }
                    placeholder={placeholder?placeholder: "Choose Service"}
                    _selectedItem={{
                    bg:"coolGray.200",
                    // endIcon: <CheckIcon size="5" />
                    }} 
                    mt={1}
                    onValueChange={onValueChange}
                    >

                        <Input
                        placeholder="Search"
                        variant="filled"
                        width="100%"
                        h={heightPercentageToDP("6%")}
                        borderRadius="10"
                        py="1"
                        px="2"
                        
                        borderWidth="0"
                        />

                        {
                            data?.map(item => {
                                return(
                                <Select.Item
                                label={item.label}
                                value={item.value}
                                />
                                )
                            })
                        }
                    </Select>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Select box of native base has prop _actionSheetBody, it contains IFlatListProps so you can use ListHeaderComponent in there. So can use this way.

  1. You use a state to save search value:

    const [searchValue, setSearchValue] = React.useState<string>('');

  2. Edit select box

`

<Select w={w} h={h} variant="outline" selectedValue={selectedValue} 
minWidth="200"
accessibilityLabel={accessibilityLabel?accessibilityLabel: "Choose Service" }
                        placeholder={placeholder?placeholder: "Choose Service"}
                        _selectedItem={{
                        bg:"coolGray.200",
                        // endIcon: <CheckIcon size="5" />
                        }} 
                        mt={1}
                        onValueChange={onValueChange}
                        _actionSheetBody={{
                            ListHeaderComponent: <FormControl px={3} mb={3}>
                                <Input
                                    px={15}
                                    py={2}
                                    fontSize={16}
                                    value={searchValue}
                                    placeholder=""
                                    _focus={{ bg: colors.white['50'], borderColor: 'darkBlue.600' }}
                                    type='text'
                                    onChangeText={(value: string) => {
                                        setSearchValue(value);
                                    }}
                                />
                            </FormControl>
                        }}
                        >
                            <Input
                            placeholder="Search"
                            variant="filled"
                            width="100%"
                            h={heightPercentageToDP("6%")}
                            borderRadius="10"
                            py="1"
                            px="2"
                            borderWidth="0"
                            />
                            {
                                (data && data.length)?data.filter((item)=>{
                                    // you filter with searchValue 
                                    return true;
                                }).map(item => {
                                    return(
                                    <Select.Item
                                    label={item.label}
                                    value={item.value}
                                    />
                                    )
                                })
                            }
                        </Select>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda